FROM node:20 AS builder

ENV APP_HOME /code/bbs-go/admin
WORKDIR "$APP_HOME"

COPY package.json ./package.json
COPY pnpm-lock.yaml ./pnpm-lock.yaml
# RUN npm install -g pnpm --registry=https://registry.npmmirror.com
# RUN pnpm install --registry=https://registry.npmmirror.com
RUN npm install -g pnpm
RUN pnpm install

COPY . ./
RUN pnpm build:docker

FROM nginx:latest

COPY --from=builder /code/bbs-go/admin/dist /usr/share/nginx/html
COPY default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
